import requests

# 添加员工
url = "http://ihrm2-test.itheima.net/api/sys/user"
header = {"Content-Type": "application/json", "Authorization": "Bearer b0275e18-6ff9-4818-ac6d-b865178bf6e7"}
json = {
    "username": "业务猪001",
"mobile": "13978734184",
"workNumber": "9527"
}
resp = requests.post(url = url, headers= header, json= json)
print(resp.json())


# 查询员工
url_quary = "http://ihrm2-test.itheima.net/api/sys/user/1561651686789885952"
header_quary = {"Content-Type": "application/json", "Authorization": "Bearer b0275e18-6ff9-4818-ac6d-b865178bf6e7"}
resp_quary = requests.get(url = url_quary, headers= header_quary)
print(resp_quary.json())


#修改员工
url_modify = "http://ihrm2-test.itheima.net/api/sys/user/1561651686789885952"
header_modify = {"Content-Type": "application/json", "Authorization": "Bearer b0275e18-6ff9-4818-ac6d-b865178bf6e7"}
json_modify = {
    "username": "x业务猪",
"mobile": "13978732783",
"workNumber": "9524"
}
resp_modify = requests.put(url = url_modify, headers= header_modify, json= json_modify)
print(resp_modify.json())

#删除员工
url_del = "http://ihrm2-test.itheima.net/api/sys/user/1561651686789885952"
header_del = {"Content-Type": "application/json", "Authorization": "Bearer b0275e18-6ff9-4818-ac6d-b865178bf6e7"}
resp_del = requests.delete(url = url_del, headers= header_del)
print(resp_del.json())
